import Vue from 'vue'
import Vuex from 'Vuex'
import state from './state.js'
import mutations from './mutations.js'
Vue.use(Vuex)
export default new Vuex.Store({
//   vuex 共用数据区 store
  state: state,
  actions: {
    // 通过List.vue中 clickToChangeCity的dispatch方法派发了
    // changeCity 方法给了Vuex
    changeCity (ctx, city) {
      // actions 派发内容给mutations
      ctx.commit('changeCity', city)
    }
  },
  // component 将方法派发给actions后 actions将会
  // 调用mutations
  mutations: mutations
})
